GEO 3/330 Exercise #1
Exploration of Transportation Mode Share in the US using Census Journey to Work Data
Purpose
This exercise uses means of transportation to work data to evaluate division, state and county-level commuting trends of workers across the United States between 2010 and 2021. Students will use census geography and attribute data to create maps, tables and figures that support the exploration of work commuting behavior by means of transportation (e.g., drive alone, bicycle, walking). The R code that was used to create the tables and maps is provided for reference but you don’t need to use R to complete exercise.
Step 1. Download exercise template and data
Download the exercise PowerPoint template and journey to work data (as Excel spreadsheet) from GitHub using the provided links. Note that these resources are also available on D2L under the exercise #1 content folder. You will use the Excel table to explore data and format tables and figures that will be shared and summarized in your PowerPoint presentation. You will also draw from resources on this page (e.g., maps) to complete your presentation. For now, just download the template and spreadsheet.
Journey to work data
For this exercise, students will examine trends in commute mode share across US divisions, states and counties over the past decade using a curated dataset. The data were downloaded using the censusapi package in RStudio. The package leverages the US Census Bureau’s application programming interface (API), which supports custom queries and downloads of ACS and other census data. Other R packages used to import data as well as create maps, tables and figures for this exercise include tigris, dplyr, tidyverse, sf, and leaflet.
Code
library(censusapi) # used to download census attribute data
library(tigris) # used to download census geographies/geometries
library(tidyverse) # used for data wrangling
library(data.table) # used for data wrangling
library(DT) # used for formatting tables
library(tidyr) # used for data wrangling
library(dplyr) # used for data wrangling
library(openxlsx) # used for reading/writing from/to Excel
library(sf) # used for reading geography data
library(leaflet) # used for creating interactive maps
library(plotly)
library(ggplot2)
library(oceanis) # used for exporting maps to pngThe commute mode share data by US county were obtained from table B08301 of the American Community Survey 5-year estimates. These estimates represent data collected over a 5-year period of time (which increases the statistical reliability of the data).
The American Community Survey (ACS) is an ongoing survey that covers a broad range of topics including the social, economic, demographic, and housing characteristics of the US population. The US census also collects “journey to work” information that can be used for a variety of planning and policy purposes including those related to sustainable transportation.
The journey to work data represent responses to a specific question administered in the survey: “How did this person usually get to work last week? If this person used more than one mode of transportation, they were asked to select the transportation mode used for most of the distance. For example, respondents would select “bicycle” or “walk” only if that mode represented most of the commute distance. In this way, the ACS only captures the primary commuting mode for the week before the survey, which may not represent the annual commuting mode share. Such limitation notwithstanding, the ACS represents the most reliable source for longitudinal changes in commute share data across the US.
Code
# Tables and years to download
grouplist <- c("B08301")
yearlist <- c(2010:2021)
# Download attribute data from ACS by county
for (agroup in grouplist) {
for (ayear in yearlist) {
agroupname = paste("group(",agroup,")",sep="")
acs_group <- getCensus(name = "acs/acs5",
vintage = ayear,
vars = c("NAME", "B01001_001E",agroupname),
region = "county:*", # tracts
# regionin="*", # places, counties, not msas
key="8f6a0a83c8a2466e3e018a966846c86412d0bb6e")
attach(acs_group)
acs_group <- acs_group %>% select(-contains(c("EA",
"MA",
"GEO_ID",
"M_1",
"M")))
acs_group$year<-ayear # append data with data year
acs_group$GEOID_county<-paste0(state,county)
assign(paste(agroup,"county",ayear,sep="_"),acs_group)
rm(acs_group)
detach(acs_group)
}
}
apattern <- paste(agroup,"county",sep="_")
alist_dfs <- mget(ls(pattern = apattern))
modeshare_county_2000_2021 <- rbindlist(alist_dfs)
# Download census geographies using tigris
us_states_geom <- states(class="sf")
us_counties_geom <- counties(class="sf", cb=TRUE, resolution = "20m")
us_divisions_geom <- divisions(class="sf", resolution = "20m")
# reformat data, column names for ease of use
# transform mode share from counts to percentages
modeshare_county_2000_2021_formatted <- modeshare_county_2000_2021 %>%
left_join(us_states_geom %>%
st_drop_geometry() %>%
select(
state_name = NAME,
GEOID_state = STATEFP,
GEOID_division = DIVISION),
by = c("state" = "GEOID_state")) %>%
left_join(us_divisions_geom %>%
st_drop_geometry() %>%
select(
division_name = NAME,
GEOID_division = GEOID),
by = "GEOID_division") %>%
drop_na(division_name) %>%
rename(county_name = NAME,
total_population = B01001_001E,
workers16pl = B08301_001E,
drovealone = B08301_003E,
carpool = B08301_004E,
transit = B08301_010E,
taxi = B08301_016E,
motorcycle = B08301_017E,
bicycle = B08301_018E,
walk = B08301_019E,
fromhome = B08301_021E) %>%
mutate(other = workers16pl - drovealone - carpool - transit - taxi - motorcycle - bicycle - walk - fromhome,
pct_drovealone = drovealone/workers16pl*100,
pct_carpool=carpool/workers16pl*100,
pct_transit=transit/workers16pl*100,
pct_taxi=taxi/workers16pl*100,
pct_motorcycle=motorcycle/workers16pl*100,
pct_bicycle=bicycle/workers16pl*100,
pct_walk=walk/workers16pl*100,
pct_fromhome=fromhome/workers16pl*100,
pct_other=other/workers16pl*100) %>%
select(GEOID_county,
county_name,
state_name,
division_name,
year,
total_population,
workers16pl,
total_population,
drovealone,
carpool,
transit,
taxi,
motorcycle,
bicycle,
walk,
fromhome,
pct_drovealone:pct_other)Step 2. Evaluate trends in journey to work over time
Open the Exercise_01.xlsx Excel spreadsheet. Here you will find 4 worksheets. Open the mode share trends dashboard worksheet. This worksheet allows you to display commute mode share over time for counties within selected census divisions, states by transportation mode. When you click a census division (e.g., East South Central) on the far left panel, the associated states (Alabama, Kentucky, Mississippi and Tennessee) are automatically selected. Click the filter button on the upper right of the associated panels to clear and begin a new query.
What changes and trends do you see in mode share over this decade long period? How do these trends differ across counties by census division and state? Speculate as to what factors may explain any differences and/or similarities between locations. Create a couple custom charts that are of interest to you; that display mode share for a specific area of the country (i.e., state or division) and transportation mode over time. Copy each chart to your exercise PowerPoint presentation (slide 1) and summarize your insights in the space provided.
The figures below show (a) the interquartile range of each transportation mode across all counties (Figure 1); and (b) trends in commute mode share over time for select modes (Figure 2).
Code
plot_ly(modeshare_county_2000_2021_pivoted,
y = ~percent,
color = ~reorder(mode,order),
type = "box",
jitter = 0.5,
boxpoints = 'suspectedoutliers',
quartilemethod="inclusive",
marker = list(size = 0.75)) %>%
config(displaylogo = FALSE,
modeBarButtons = list(modeBarButtonsList)) %>%
layout(yaxis = list(title = 'Commute Mode Share (%)'),
xaxis = list(title = 'Travel Mode'),
showlegend = FALSE)Code
plot_ly(data = modeshare_county_2000_2021_formatted %>%
select(year,pct_fromhome, pct_bicycle, pct_transit, pct_walk) %>%
drop_na() %>%
group_by(year) %>%
summarise(`from home` = mean(pct_fromhome),
`bicycle` = mean(pct_bicycle),
`walk` = mean(pct_walk),
`transit` = mean(pct_transit)),
x = ~year,
y = ~`from home`,
type = 'scatter',
mode = 'lines+markers',
marker = list(color = "#E0A100"),
line = list(color = "#E0A100"),
name = 'from home',
hovertemplate = 'from home: %{y:.1f}<extra></extra>') %>%
add_trace(x = ~year,
y = ~`walk`,
type = 'scatter',
mode = 'lines+markers',
marker = list(color = "#9F1928"),
line = list(color = "#9F1928"),
name = 'walk',
hovertemplate = 'walk: %{y:.1f}<extra></extra>') %>%
add_trace(x = ~year,
y = ~`transit`,
type = 'scatter',
mode = 'lines+markers',
marker = list(color = "#009BA6"),
line = list(color = "#009BA6"),
name = 'transit',
hovertemplate = 'transit: %{y:.1f}<extra></extra>') %>%
add_trace(x = ~year,
y = ~`bicycle`,
type = 'scatter',
mode = 'lines+markers',
marker = list(color = "#080967"),
line = list(color = "#080967"),
name = 'bicycle',
hovertemplate = 'bicycle: %{y:.1f}<extra></extra>') %>%
layout(
xaxis = list(title = ""),
yaxis = list(title = "Commute Mode Share (%)"),
legend=list(
font = list(
size = 10
),
orientation = "h",
xanchor="center",
x = 0.5, y=-0.1),
hovermode = "x unified")Step 4. Add selected maps to presentation
Once downloaded, the geographies can be joined with attribute data to make meaningful maps. Download links to static versions of the maps to copy and paste into PowerPoint template. Figure 3 presents maps presents interactive commute mode share by county across the US for select travel modes. Hover over each county to identify its associated census division, state and respective mode shares. Do you see anything peculiar in these geographic distributions? Why do regions perform differently/similarly? Identify two (or more) maps you’d like to include in your presentation (slides 6, 7). Save the maps to your computer using the “static map” links located by the figure’s caption. Summarize your insights in the presentation.
Step 5. Submit your completed presentation
Navigate to the course D2L page. Submit/upload your exercise #1 presentation to the appropriate submission folder. Good work!